import { defineConfig, loadEnv  } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'

export default defineConfig(({ command, mode })=>{

  const env = loadEnv(mode, process.cwd(), '')

  return {
    resolve:{
      alias:{
        "~":path.resolve(__dirname,"src")
      }
    },
    plugins: [vue()],
    server: {
      port: 7000,
      proxy:{
        [env.VITE_PROXY_API]: {
          target: env.VITE_BASE_API,
          changeOrigin: true,
          rewrite : (path) => path.replace(new RegExp(`^${env.VITE_PROXY_API}`), '')
        },
      }
    }
  }
})